﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using WalkingTec.Mvvm.Core;
using WalkingTec.Mvvm.Core.Extensions;
using Microsoft.EntityFrameworkCore;
using System.ComponentModel.DataAnnotations;
using SelfService.Model.Models;
using SelfService.Model;


namespace SelfService.ViewModel.SysModuleVMs
{
    public partial class SysModuleListVM : BasePagedListVM<SysModule_View, SysModuleSearcher>
    {

        protected override IEnumerable<IGridColumn<SysModule_View>> InitGridHeader()
        {
            return new List<GridColumn<SysModule_View>>{
                this.MakeGridHeader(x => x.Name),
                this.MakeGridHeader(x => x.Description),
                this.MakeGridHeader(x => x.IsEnable),
                this.MakeGridHeaderAction(width: 200)
            };
        }

        public override IOrderedQueryable<SysModule_View> GetSearchQuery()
        {
            var query = DC.Set<SysModule>()
                .CheckContain(Searcher.Name, x=>x.Name)
                .CheckEqual(Searcher.IsEnable, x=>x.IsEnable)
                .Select(x => new SysModule_View
                {
				    ID = x.ID,
                    Name = x.Name,
                    Description = x.Description,
                    IsEnable = x.IsEnable,
                })
                .OrderBy(x => x.ID);
            return query;
        }

    }

    public class SysModule_View : SysModule{

    }
}
